<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ page import="com.hzqy.commons.utils.ConstantUtils" %>
<%@ taglib prefix="limits" uri="/WEB-INF/tld/limits.tld"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<title>内容管理</title>
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/defalut.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/public.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/ddspstyle.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/icon.css">
<link href="../../static/css/uploadify.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css"	href="../../static/js/WdatePicker/skin/WdatePicker.css">


<script type="text/javascript" src="../../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../../static/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../../static/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../static/js/index.js"></script>
<script type="text/javascript" src="../../static/js/WdatePicker/WdatePicker.js"></script>
<script src="../../static/js/jquery.uploadify.js" type="text/javascript"></script>
<%
String myIp = session.getServletContext().getInitParameter("img_url");
String []nonceObj=ConstantUtils.getNonceObject();
%>


<script type="text/javascript">
		var queryParams;
		function EasyuiDatagrid() {
			$("#easyui-datagrid").datagrid({
				url: '../../content/content_list.do',
				nowrap: true,
				striped: true,
				border: false,
				fit: true,
				rownumbers:true,
				queryParams: getGueryParams(),
				columns: [[
					{field:'id',checkbox:true},
					{field:'f_cc_id',title:"模板ID",align:"center",width:75},
					{field:'f_cc_companyname',title:'行业客户',align:'center',width:150},
					{field:'f_cc_name',title:'模板名称',align:'center',width:150},
					{field:'f_cc_desc',title:'路径',align:'center',width:150},
					{field:'f_cc_viewindex',title:'是否上传模板',align:'center',width:60,
						formatter:function(value,row,index) {
							var status = "否";
							if(value==0){
								status="否";
							} else if(value==1){
								status="是";
							}
							return status;
						}},
					{field:'f_cc_end',title:'类型',align:'center',width:150,
						formatter:function(value,row,index) {
							var status = "未知";
							switch(value){
							case 0:
								status="百视通酒店标清";
								break;
							case 1:
								status="百视通政企标清";
								break;
							case 2:
								status="百视通酒店高清";
								break;
							case 3:
								status="百视通温台酒店高清";
								break;
							case 4:
								status="百视通政企高清";
								break;
							case 5:
								status="百视通温台政企高清";
								break;
							case 6:
								status="广电酒店标清";
								break;
							case 7:
								status="广电酒店高清";
								break;
							case 8:
								status="中兴百视通公众";
								break;
							case 9:
								status="中兴百视通酒店";
								break;
							case 10:
								status="中兴广电标清";
								break;
							case 11:
								status="中兴广电高清";
								break;
							case 12:
								status="广电公众";
								break;
							case 13:
								status="广电公众高清";
								break;
							}
							return status;
						}	
					},
					{field:'f_cc_isfree',title:'是否通用',align:'center',width:60,
						formatter:function(value,row,index) {
							var status = "通用";
							if(value==0){
								status="通用";
							} else if(value==1){
								status="个性";
							}
							return status;
						}	
					},
					{field:'f_cc_status',title:'状态',align:'center',width:60,
						formatter:function(value,row,index) {
							var status = "未知";
							if(value==1){
								status="上线";
							} else if(value==2||value==16||value==14){
								status="待审核";
							} else if(value==4||value==13||value==15){
								status="审核未通过";
							}
							return status;
						}	
					},
					{field:'f_cc_director',title:'上传人',align:'center',width:80,
						formatter:function(value,row,index) {
							return value;
						}	
					},
					{field:'f_cc_remark',title:'审核备注',align:'center',width:80,
						formatter:function(value,row,index) {
							var str="";
							if(row.f_cc_status==4||row.f_cc_status==13){
								str=value;
							}
							return str;
						}	
					},
					{field:'f_cc_cdate',title:'上传时间',align:'center',width:150},
					{field:'_parentId',title:'关联行业客户预览',align:'center',width:110,
						formatter:function(value,row,index){
							var str="";
							str+= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="showOrgList('+row.f_cc_id+')" ><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">详情</span></span></a>';
					    	return str;
				    	}
					},
					{field:'_parentId11',title:'操作',align:'center',width:500,
						formatter:function(value,row,index){
							var str ="";
							if(row.model_num==0){
								str+= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="onClickBtnDelete('+row.f_cc_id+')" ><span class="l-btn-left"><span class="l-btn-text icon-remove l-btn-icon-left">删除</span></span></a>';	
							}else{
								str+= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="exportExcel('+row.f_cc_id+')" ><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">关联行业客户导出</span></span></a>';
							}
							if(row.f_cc_status==2 ||row.f_cc_status==1||row.f_cc_status==4||row.f_cc_status==13){
								str+= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="edit(\''+row.f_cc_id+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">修改</span></span></a>';	
							}
							<limits:uiAuth url="pretrialContent.do">	
							str+= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="onClickBtnpretrial('+row.f_cc_id+')" ><span class="l-btn-left"><span class="l-btn-text icon-reload l-btn-icon-left">审核解压</span></span></a>';
							</limits:uiAuth>
							str+= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="download_model('+row.f_cc_id+');" ><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">下载</span></span></a>';	
							<limits:uiAuth url="review_content.do">	
								<limits:uiAuth url="city_review_power">	
					    		if(row.f_cc_status==2 || row.f_cc_status==4) {
					    			str+='<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="review(\''+row.f_cc_id+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-ok l-btn-icon-left">市公司审核</span></span></a>';
					    		}
					    		</limits:uiAuth>
					    		//省公司审核
					    		<limits:uiAuth url="province_review_power">	
					    		if(row.f_cc_status==16 || row.f_cc_status==13) {
					    			str+='<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="review(\''+row.f_cc_id+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-ok l-btn-icon-left">省公司审核</span></span></a>';
					    		}
					    		</limits:uiAuth>
				    		</limits:uiAuth>
					    	return str;
				    	}
					}
				]],
				singleSelect:true,
				pagination:true,
				pageList:[10,20,30,40,50],
				pageSize:10,
				toolbar: '#toolbar',
				
				onExpandRow: function(index,row){
				
				},
				onSelect: function(rowIndex,rowData) {
					
				},
				onUnselect: function(rowIndex,rowData) {
					
				},
				onCheckAll: function(rowIndex,rowData) {
					
				},
				onUncheckAll: function(rowIndex,rowData) {
				
				},
				onLoadSuccess: function(data) {
					if(data.total==-1) {
						$.messager.defaults={ok:"确定",cancel:"取消"};
						$.messager.confirm('提示', '用户尚未登录,请登录', function(r){
						if (r){
						    window.parent.location.href='/login.do';
						    return false;
						}});
					}
				}
			});
		}
	
		function getGueryParams(){
			return {
				f_cc_name:$("#f_cc_name").val(),
				sctt_startDate:$("#sctt_startDate").val(),
				sctt_endDate:$("#sctt_endDate").val(),
				f_cc_type:20
			};
		}
		
		$(function(){
			new EasyuiDatagrid();
			gotoSearch = function(){
				$("#easyui-datagrid").datagrid('reload',getGueryParams());
			};
			onClickBtnDelete = function(id){
				$.messager.confirm('确定删除模板','确定删除模板么?',function(r){
					if(r){
						app_ajax('../../content/delete_content.do?f_cc_id='+id+'&stime=<%=nonceObj[0]%>&sign=<%=nonceObj[1]%>',
						'',
						function(msg){
							if(msg.success) {
								alert("删除成功!");
								if (checkAjaxRequestValidity(msg)) {
									gotoSearch($('#easyui-treegrid'));
								}
							} else {
								alert("删除异常，请联系管理员");
								if($.isFunction(window.showMessager)){
									window.showMessager(msg.resultTitle,msg.result);
								}
							}
							window.location.reload();
						}
						);
					}
				});
			};
			onClickBtnpretrial = function(id){
				$.messager.confirm('确定解压模板','确定解压模板么?',function(r){
					if(r){
						app_ajax('../../content/pretrialContent.do?f_cc_id='+id,
						'',
						function(msg){
							if(msg.success) {
								alert("解压成功!");
								if (checkAjaxRequestValidity(msg)) {
									gotoSearch($('#easyui-treegrid'));
								}
							} else {
								alert("解压异常，请联系管理员");
								if($.isFunction(window.showMessager)){
									window.showMessager(msg.resultTitle,msg.result);
								}
							}
						}
						);
					}
				});
			};
		});
		
		function load(){
			$(".datagrid-row-expander datagrid-row-expand").attr("display","none"); 
		}
		
		function download_model(_f_cp_relationid){
			$.ajax({
				url:"../../picture/selectPictureList.do?f_cp_relationid="+_f_cp_relationid+"&picType=模板",
				type:"POST",
				dataType:"json",
				success:function(resultObj){
					
					if(resultObj){
						var data = resultObj.list;
						window.open("<%=myIp%>"+data[0].f_cp_url);
					}
				}
			});
		}
		function onpress(){
			var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异
	   		  	if (event.keyCode == 13){  
	      			gotoSearch($('#easyui-treegrid'));
	    		}
		}
		function exportExcel(f_po_model_){
			var url="../../content/selectOrgListByModelOutExcel.do?f_po_model="+f_po_model_;
	        window.open(url);
		}
		function edit(id){
			/* var rows = $("#easyui-datagrid").datagrid('getSelections');
			if(rows.length <= 0) {
				alert("请至少选择一条记录!");
			} else { */
				openDialog($("#dlg"),'model_update.jsp?f_cc_id='+id);
			/* }
			 */
		}
		function review(id){
			openDialog($('#dlg'),'model_review.jsp?f_cc_id='+id);
		}
		function showOrgList(id){
			openDialog($('#dlg'),'model_org_list.jsp?f_cc_id='+id);
		}
		function add(){
			openDialog($('#dlg'),'model_add.jsp');
		}
	</script>
</head>
<body onload="load();" style="width: 100%;">
	<input type="hidden" id="sessionId" value="${pageContext.session.id}" />
	<table id="easyui-datagrid" title="模板管理"></table>
	<div id="toolbar" class="easyui_datagrid_toolbar" style="">
		<div class="easyuiSearch">
			<form onsubmit="return false;" method="post">
			<input type="hidden" name="f_cc_type" value="20"/>
				<table cellspacing="0" cellpadding="0" width="90%">
					<tr>
						<td align="left" width="7%">模板名称：</td>
						<td align="left" width="15%"><input name="f_cc_name" id="f_cc_name" style="width: 150px;" onkeydown="onpress();" /></td>
						<td align="left" width="7%">添加时间：</td>
						<td align="left" width="15%"><input name="sctt_startDate" id="sctt_startDate" onClick="WdatePicker({skin:'default',dateFmt: 'yyyy-MM-dd HH:mm:ss'})" style="width: 150px;" /></td>
						<td>--</td>
						<td><input name="sctt_endDate" id="sctt_endDate"onClick="WdatePicker({skin:'default',dateFmt: 'yyyy-MM-dd HH:mm:ss'})" style="width: 150px;"  /></td>
						
					</tr>
					<tr>
						<td align="left" width="10%">
								<a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-add', plain:true" onclick="add()">增加内容</a>
						</td>
						<!-- <td align="left" width="10%">
								<a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-add', plain:true" onclick="edit()">修改</a>
						</td> -->
						<td align="left" width="15%">
							<limits:uiAuth url="content_list.do">
								<a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-search', plain:true"
									onclick="gotoSearch($('#easyui-datagrid'))">查询</a>
							</limits:uiAuth>
						</td>
					</tr>
				</table>
			</form>
		</div>
		<div style="margin-bottom: 5px">
			<!-- <a href="javascript:void(0)" class="easyui-linkbutton" onclick="delete();" iconCls="icon-cut" plain="true">删除</a>  -->
		</div>
	</div>
	<div id="dlg" class="easyui-dialog"
		style="width: 850px; height: 500px; padding-top: 0px;"
		data-options="title:'模板管理', iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
		<iframe scrolling="auto" frameborder="0"
			style="width: 100%; height: 99%;"></iframe>
	</div>
</body>
</html>